'use strict';
var Schema = require('mongoose').Schema,
    Model = require('../../../Base/server/controllers/Model');

var modelField = {
    // Org: {
    //     type: Schema.ObjectId,
    //     Name: '组织',
    //     ref: 'Org'        
    // },
    Work: {
	    type: Schema.ObjectId,
	    ref: 'Work',
	    Name: '作业',
	    IsEmpty: false
	},
	// Asset: {
    //     type: Schema.ObjectId,
    //     Name: '设备',
    //     ref: 'Asset'        
    // },
    ItemMaster: {
	    type: Schema.ObjectId,
	    ref: 'ItemMaster',
	    Name: '料品',
	    IsEmpty: false
	},
	Department: {
        type: Schema.ObjectId,
        Name: '部门',
        ref: 'Department'
    },
    BizDate: {
	    type: Date,
	    Name: '流水日期',
	    IsEmpty: false
	},
	CompleteQty: {
	    type: Number,
	    Name: '当期产量',
	    default: 0
	},
	ReworkQty: {
	    type: Number,
	    Name: '当期返工',
	    default: 0
	},
	ScriptQty: {
	    type: Number,
	    Name: '当期报废',
	    default: 0
	},
	DescSeg1: {
	    type: String,
	    default: '',
	    trim: true,
	    Name: '扩展字段1'
	},
	DescSeg2: {
	    type: String,
	    default: '',
	    trim: true,
	    Name: '扩展字段2'
	},
	DescSeg3: {
	    type: String,
	    default: '',
	    trim: true,
	    Name: '扩展字段3'
	},
	Users: {
	    type: [{
	        type: Schema.ObjectId,
	        ref: 'User'
	    }],
	    Name: '用户'
	}
};

var newModel = new Model(modelField);
newModel.addIndex({Work: 1, ItemMaster: 1, Department: 1,Users: 1, BizDate: 1, DescSeg1: 1, DescSeg2: 1, DescSeg3: 1}, {"unique": true});
newModel.create('WorkOutput', '作业产量');